# -*- coding: utf-8 -*-
import datetime

from core.sqlite3db.SqliteInner import SqliteInner
from core.sqlite3db.SqliteSql import SqliteSql
from core.storeinfo import StoreInfo
from tools.OperationError import OperationError
from webapp.config import Config
import json
from tools.httpdoer import Request
import tools.convert as convert
from tools.linq import linq
import tools.globalvar as globalvar

product = {
    "ProductName": "",  # 品名
    "Color": "-1",  # 颜色
    "Size": "-1",  # 尺码
    "StandardPrice": "",  # 标准价格
    "PriceReceivable": "",  # 应收价格
    "Number": "",  # 数量
    "RealIncomePrice": "",  # 实收价格
    "AmountCollected": "",  # 实收金额
    "SalesClerk": "",  # 营业员
    "RetailType": "",  # 零售类型
    "ExtensionType": "",  # 推广类型
    "BarCode": "",  # 条码
    "SalerId": -1,  # 营业员ID
    "Saler": "",  # 营业员
    "Type": None,  # 零售类型
    "OrgdocNo": 0,  # 原单号
    "LineId": -1,  # 行号
    "PdaId": 0,  # 款号ID
    "ProductId": 0,  # 条码ID
    "Taxrate": 0,  # 销售比例
    "Proyear": "",  # 年份
    "Numdim6": "",  # 类别
    "Largeclass": "",  # 大类
    "Sex": "",  # 性别
    "Prosea": '',  # 季节
    "Proline": '',  # 产品线
    "Promotiontype": '',  # 推广类型
    "Numdim5": '',  # 产品结构类型
    "Series": '',  # 风格
    "Numdim7": '',  # 系列
    "Proband": "",  # 波段
    "Pronature": '',  # 商品性质
    "Numdim8": "",  # 客群
    "Priceband": '',  # 价格带
    "Prostandard": '',  # 执行标准
    "Prosource": '',  # 商品来源
    "Supbrand": "",  # 供应商品牌
    "PsCSpecobjIds": ''  # 规格字典ID集合
}


class Order:
    # 单据头
    order = {}
    products = []  # 录入的所有商品明细信息
    temp_products=[]#存放经过计算的临时商品数据


def AddProduct(products):
    if products:
        for i in range(len(products)):
            row_item = {}
            row_item["BarCodeId"] = products[i][0]  # 条码ID
            row_item["BarCode"] = products[i][1]  # 条码
            row_item["ProductId"] = products[i][2]  # 款号ID
            row_item["DistribId"] = products[i][3]  # 配销中心ID
            row_item["DistribidCode"] = products[i][4]  # 配销中心编码
            row_item["DistribidName"] = products[i][5]  # 配销中心名称
            row_item["BrandId"] = products[i][6]  # 品牌ID
            row_item["BrandCode"] = products[i][7]  # 品牌编码
            row_item["BrandName"] = products[i][8]  # 品牌名称
            row_item["ProductCode"] = products[i][9]  # 款号编码
            row_item["ProductName"] = products[i][10]  # 款号名称
            row_item["TxtDim3"] = products[i][11]  # 商品特征
            row_item["PriceList"] = float(products[i][12])  # 吊牌价
            row_item["PriceLower"] = float(products[i][13])  # 零售价下限
            row_item["Prouear"] = products[i][14]  # 年份
            row_item["NumDim6"] = products[i][15]  # 类别
            row_item["LargeClass"] = products[i][16]  # 大类
            row_item["Sex"] = products[i][17]  # 性别
            row_item["Prosea"] = products[i][18]  # 季节
            row_item["PromotionType"] = products[i][19]  # 推广类型
            row_item["NumDim5"] = products[i][20]  # 产品结构类型
            row_item["Series"] = products[i][21]  # 风格
            row_item["Proband"] = products[i][22]  # 波段
            row_item["Pronature"] = products[i][23]  # 商品性质
            row_item["NumDim8"] = products[i][24]  # 客群
            row_item["PriceBand"] = products[i][25]  # 价格带
            row_item["NumDim9"] = products[i][26]  # 外观
            row_item["NumDim3"] = products[i][27]  # 买手
            row_item["NumDim11"] = products[i][28]  # 版型
            row_item["Spec1Code"] = products[i][29]  # 颜色编码
            row_item["Spec1Name"] = products[i][30]  # 颜色名称
            row_item["Spec2Code"] = products[i][31]  # 尺寸编码
            row_item["Spec2Name"] = products[i][32]  # 尺寸名称
            row_item["Spec1Id"] = products[i][33]  # 颜色ID
            row_item["Spec2Id"] = products[i][34]  # 尺寸ID
            row_item["Fabdesc"] = products[i][35]  # 商品FAB
            row_item["Qty"] = products[i][36]  # 数量
            row_item["RetailType"] = products[i][37]  # 零售类型
            row_item["SalerId"] = products[i][38]  # 营业员ID
            row_item["Saler"] = products[i][39]  # 营业员名称
            row_item["LineNo"] = len(Order.products) + 1  # 行号
            row_item["Discount"] = 1  # 折扣
            row_item["RetailPrice"] = ("%.2f" % (float(row_item["PriceList"])))  # 零售价格(没有调价单就是吊牌价)
            row_item["ReceivablePrice"] = ("%.2f" % (float(row_item["PriceList"])))  # 应收价格(没有调价单就是吊牌价)
            row_item["ActualPrice"] = ("%.2f" % (float(row_item["ReceivablePrice"]) * row_item["Discount"]))  # 实收价格
            row_item["Price"] = ("%.2f" % (float(row_item["ActualPrice"]) * int(row_item["Qty"])))  # 实收金额
            if not MergeProduct(row_item):
                Order.products.append(row_item)


def AddOrder(ordercur):
    if ordercur:
        for i in range(len(ordercur)):
            Order.order = {}
            Order.order["BillNO"] = ordercur[i][0]  # 单号
            Order.order["Billdate"] = ordercur[i][1]  # 时间


def initOrder():
    Order.order = {}
    # 5位店仓编码 + 2位POS机编号 + 6位年月日 + 6位时分秒 + 4位流水
    storeinfo = StoreInfo()
    storeobject = storeinfo.getStoreInfo()
    storeNO = storeobject.get("CP_C_STORE_ECODE","")
    if storeNO == None:
        raise OperationError(-1, "店仓编码为空")
    posCode = storeobject.get("POS_CODE", "")
    if posCode == None:
        raise OperationError(-1, "POS机编号为空")
    nowDate = datetime.datetime.now().strftime('%Y%m%d')  # 现在
    nowTime = datetime.datetime.now().strftime('%H%M%S')  # 现在
    #查询数据库里当天日期最大的流水号
    sqliteinit = SqliteInner()
    db = sqliteinit.setConnetion("master")
    sql = SqliteSql.getRetailMaxBillNO % (nowDate)
    cur = sqliteinit.execute(sql)
    print(cur)
    sqliteinit.closedb()
    #解析单号
    if cur != None and len(cur) > 0:
        if type(cur) == list:
            columns = cur[0]
            column = columns[0]
            if None == column:
                column = "0001"
            else :
                if len(column) > 4:
                    column = column[-4:]  # 截取倒数第四位到结尾
                    column = int(column) + 1
                    print(column)
                else:
                    raise OperationError(-1, "上次单据号错误")

            Order.order["BillNO"] = storeNO + posCode + nowDate + nowTime + column  # 单号
        else:
            raise OperationError(-1, str(cur))
    else:
        # 查不到数据
        Order.order["BillNO"] = storeNO + posCode + nowDate + nowTime + "0001"  # 单号

    return Order.order



def MergeProduct(product={}):
    '''
    合并商品相同行
    :param product:
    :return:
    '''
    if Order.products:
        for i in range(len(Order.products)):
            row = Order.products[i]
            if row["BarCode"] == product["BarCode"] and row["ProductCode"] == product["ProductCode"] and row[
                "PriceList"] == float(product["PriceList"]) and row["RetailType"] == product["RetailType"] and row[
                "SalerId"] == product["SalerId"] and row["Discount"] == product["Discount"] and row[
                "ReceivablePrice"] == product["ReceivablePrice"]:
                if int(row["RetailType"]) == 3 or int(row["RetailType"]) == 5:
                    Order.products[i]["Qty"] =str( -int(Order.products[i]["Qty"]) + int(product["Qty"]))
                else:
                    Order.products[i]["Qty"] =str( int(Order.products[i]["Qty"]) + int(product["Qty"]))
                Order.products[i]["Price"] = ("%.2f" % (float(Order.products[i]["Price"]) + float(Order.products[i]["PriceList"]) * int(Order.products[i]["Qty"])))
                return True
        return False
    else:
        return False


def DeleteProducts(lineno=[]):
    if Order.products:
        for j in range(len(lineno)):
            d_lineno = lineno[j]
            for i in range(len(Order.products)):
                if Order.products[i]["LineNo"] == d_lineno:
                    Order.products.pop(i)
                    break

def update_product(i=-1,product={}):
    Order.temp_products = []
    Order.temp_products = Order.products
    if Order.products and i!=-1:
        Order.temp_products[i]=product


def GetProducts():
    if Order.temp_products:
        return Order.temp_products
    else:
        return Order.products


def GetProductsTotal():
    res = {}
    t_qty = 0
    t_price = 0
    _products = Order.products
    if _products:
        for i in range(len(_products)):
            t_qty = t_qty + int(_products[i]["Qty"])
            t_price = t_price + float(_products[i]["Price"])
    res["t_qty"] = t_qty
    res["t_price"] = t_price
    return res


class Retail:
    salers = {}  # 记录当前传入的营业员信息
    params_row = {}  # 记录传入的商品当前处理的行信息
    con = SqliteInner()



    def get_salersById(self,saler_id):
        try:
            salers = globalvar.get_valuebykey(Config.KEY_SALERS, [])
            if salers:
                n_saler=linq(salers).where(lambda x: x["ID"]==saler_id).tolist()
                return n_saler
        except Exception as e:
            raise OperationError(-1, str(e.__str__()))

    def SearchProducts(self, params={}):
        res = {}
        _data = []
        if params:
            try:
                self.__class__.salers = {}
                self.__class__.params_row = {}
                # self.__class__.params_row=_param[i]
                # _item=_param[i]
                products = params["product"]
                _mode = params["input_mode"]
                if _mode != 'skus':
                    self.__class__.params_row = products[0]
                    self.__class__.salers["saler_id"] = products[0]["saler_id"]
                    self.__class__.salers["saler"] = ""

                if _mode == 'blurry':
                    # 左匹配查询款号信息
                    res = Retail.getPro(self, products[0]["pro_sku"], None)
                elif _mode == 'pro':
                    # 查询详细款号信息（矩阵界面使用)
                    res = Retail.getSkusByPro(self, products[0]["pro_sku"], None)
                elif _mode == 'mixing':
                    # “商品输入框”回车键进入
                    res = Retail.getSkuOrPad(self, products[0]["pro_sku"])
                else:
                    # 条码批量录入查询所有条码详细信息
                    oldskus = GetProducts()
                    ishavesku = False;
                    if oldskus:
                        ishavesku = True
                    for i in range(len(products)):
                        self.__class__.params_row={}
                        self.__class__.salers={}
                        self.__class__.params_row = products[i]
                        self.__class__.salers["saler_id"] = products[i]["saler_id"]
                        self.__class__.salers["saler"] = ""
                        # if ishavesku:
                        #     row_sku = linq(oldskus).where(lambda x: x.BarCode is not None and x.BarCode==products[i]['pro_sku']).tolist()
                        Retail.getSkuInfo(self, products[i]['pro_sku'], None)
                    skus = GetProducts()
                    if skus:
                        res["data"] = skus
                        res["message"] = ""
                        res["code"] = 0
                        res["type"] = "sku"  # 返回的是条码信息
                        # 获取条码统计信息
                        total = GetProductsTotal()
                        res["total"] = total
                    else:
                        res["data"] = []
                        res["message"] = '商品不存在'
                        res["code"] = -1
                        res["type"] = "sku"  # 返回的是条码信息
                return res
            except Exception as e:
                res["data"] = []
                res["message"] = '商品不存在'
                res["code"] = -1
                return res
        else:
            res["data"] = []
            res["message"] = "未传入参数"
            res["code"] = -1
            return res

    def getSkuOrPad(self, product=''):
        '''
        查询条码详细信息或款号矩阵信息
        :param product: 前台传入的输入的“商品”
        :return: 返回查询出的及内存里之前查询出的所有商品信息，JSON格式
        '''
        # 按条码检索
        res = {}
        res_sku = []
        sql = SqliteSql.checkSkuCode % product.upper()
        # con = SqliteInner()
        sqlitedb = self.con.setConnetion(Config.POSBASEDB_NAME)
        try:
            res_sku = sqlitedb.execute(sql)
            if res_sku[0][0] > 0:
                # 条码存在，则查询商品详细信息
                flag = Retail.getSkuInfo(self, product, sqlitedb)
                if flag:
                    res["data"] = GetProducts()
                    res["message"] = ""
                    res["code"] = 0
                    res["type"] = "sku"  # 返回的是条码信息
                    # 获取条码统计信息
                    total = GetProductsTotal()
                    res["total"] = total
                else:
                    res["data"] = []
                    res["message"] = "商品不存在"
                    res["code"] = -1
                    res["type"] = "sku"
            else:
                # 条码检索不存在，则再按款号检索
                res_pro = []
                sql = SqliteSql.checkPro % str(product).upper()
                res_pro = sqlitedb.execute(sql)
                if int(res_pro[0][0]) > 0:
                    # 按款号检索到信息，则查询详细款号矩阵信息
                    res = Retail.getSkusByPro(self, product, sqlitedb)
                else:
                    # 则商品不存在
                    res["data"] = []
                    res["message"] = "商品不存在"
                    res["code"] = -1
        except Exception as e:
            res["data"] = []
            res["message"] = "商品不存在"
            res["code"] = -1
        finally:
            self.con.closedb()
            return res

    def getSkuInfo(self, product, sqlitedb):
        '''
        查询条码详细信息
        :param product:
        :return:
        '''
        res = []
        sql = SqliteSql.getSku % str(product).upper()
        if sqlitedb == None:
            sqlitedb = self.con.setConnetion(Config.POSBASEDB_NAME)
        res = sqlitedb.execute(sql)
        self.con.closedb()
        n_res = []
        if res:
            row = list(res[0])
            if int(self.params_row["retail_type"]) == 3 or int(self.params_row["retail_type"]) == 5:
                row.append("-"+str(self.params_row["qty"]))
            else:
                row.append(str(self.params_row["qty"]))
            row.append(str(self.params_row["retail_type"]))
            row.append(self.salers["saler_id"])
            row.append(self.salers["saler"])
            n_res.append(tuple(row))
            AddProduct(n_res)
            return True
        else:
            return False

    def getSkusByPro(self, product, sqlitedb):
        '''
        根据款号查询出所有条码及颜色尺寸，矩阵界面使用
        :param product:
        :return:
        '''
        r_res = []
        lists = []
        r_data = {}
        sql = SqliteSql.searchSpecObjids % str(product).upper()
        if sqlitedb == None:
            # con = SqliteInner()
            sqlitedb = self.con.setConnetion(Config.POSBASEDB_NAME)
        res = sqlitedb.execute(sql)
        if res:
            if res[0][1] != None:
                specobjids = json.loads(res[0][1])
                if specobjids and specobjids != None:
                    spec1 = specobjids["SPEC1"]  # 颜色ID列表
                    spec2 = specobjids["SPEC2"]  # 尺寸ID列表
                    if len(spec1) == 1:
                        spec1.append(-1)
                    if len(spec2) == 1:
                        spec2.append(-1)
                    sql = SqliteSql.getSpec1 % str(tuple(spec1)).replace('None', '-1')
                    res_spec1 = sqlitedb.execute(sql)
                    sql = SqliteSql.getSpec2 % str(tuple(spec2)).replace('None', '-1')
                    res_spec2 = sqlitedb.execute(sql)
                    sql = SqliteSql.getSkusByPro % str(product).upper()
                    res_skus = sqlitedb.execute(sql)

                    if res_spec1 and res_spec2 and res_skus:
                        for i in range(len(res_spec1)):
                            lists = []
                            row_obj = {}
                            row_spec1 = res_spec1[i]
                            row_obj["color"] = "[" + row_spec1[1] + "]" + row_spec1[2]
                            is_sku = False
                            is_spec2 = False
                            for p in range(len(res_spec2)):
                                list_item = {}
                                row_spec2 = res_spec2[p]
                                list_item["size"] = row_spec2[2]
                                for j in range(len(res_skus)):
                                    row_sku = res_skus[j]
                                    if row_sku[2] == row_spec1[0] and row_sku[3] == row_spec2[0]:
                                        list_item["BarCode"] = row_sku[1]
                                        break
                                list_item["num"] = 2
                                lists.append(list_item)
                            row_obj["list"] = lists
                            r_res.append(row_obj)
                else:
                    r_data["data"] = []
                    r_data["message"] = "款号不存在条码信息"
                    r_data["code"] = -1
                    r_data["type"] = "pro"
                    return r_data
            else:
                r_data["data"] = []
                r_data["message"] = "款号不存在条码信息"
                r_data["code"] = -1
                r_data["type"] = "pro"
                return r_data
        if r_res:
            r_data["data"] = r_res
            r_data["message"] = ""
            r_data["code"] = 0
            r_data["type"] = "pro"  # 返回的是款号信息
        else:
            r_data["data"] = []
            r_data["message"] = "款号信息未查询到"
            r_data["code"] = -1
            r_data["type"] = "pro"
        return r_data

    def getPro(self, product, sqlitedb):
        '''
        左匹配款号信息
        :param product: 输入的款号
        :param sqlitedb: 数据库实例对象
        :return: 返回dict对象
        '''
        res = {}
        new_data = []
        sql = SqliteSql.getProInfo % str(product).upper()
        if sqlitedb == None:
            # con = SqliteInner()
            sqlitedb = self.con.setConnetion(Config.POSBASEDB_NAME)
        data = sqlitedb.execute(sql)
        if data:
            for i in range(len(data)):
                row = {}
                row["ProId"] = data[i][0]
                row["ProCode"] = data[i][1]
                row["ProName"] = data[i][2]
                row["PriceList"] = float(data[i][3])
                new_data.append(row)
            res["data"] = new_data
            res["message"] = ""
            res["code"] = 0
        else:
            res["data"] = []
            res["message"] = "商品不存在"
            res["code"] = -1

        return res

    def get_productpic(self, product=''):
        '''
        获取商品的图片
        :param product:款号
        :return:JSON
        '''
        res = {}
        try:
            request = Request("http://172.16.8.18:8080/api/cpro/QuerySkuImage")
            request.method = "post"  # 调用 _set_method
            # request.timeout = 10  # 调用 _set_timeout
            request.path_params = None
            request.body = {"param": convert.to_json_string(
                {"ECODE": product, "CP_C_DISTRIB_ID": 1240})}
            r = request.send(json=False)
            texts = json.loads(r.text)
            if r.status_code == 200:
                res["code"] = 0
                res["data"] = texts["data"]
                res["message"] = texts["message"]
            else:
                res["code"] = -1
                res["data"] = []
                res["message"] = texts["message"]

        except Exception as e:
            res["code"] = -1
            res["data"] = []
            res["message"] = e
        return res

    def delete_pro(self, LineNo=[]):
        '''
        删除传入的行商品数据
        :param LineNo:
        :return:
        '''
        if LineNo:
            DeleteProducts(LineNo)
        res = {}
        res["code"] = 0
        res["data"] = GetProducts()
        res["message"] = ""
        # 获取条码统计信息
        total = GetProductsTotal()
        res["total"] = total
        return res

    def update_qty(self,products=[]):
        '''
        修改相应行的数量
        :param products:
        :return:
        '''
        res = {}
        try:
            pros = GetProducts()
            if pros:
                if products:
                    for i in range(len(products)):
                        u_item=products[i]
                        u_lineno=u_item["lineno"]
                        new_products={}
                        for j in range(len(pros)):
                            old_item=pros[j]
                            old_lineno=old_item["LineNo"]
                            if str(u_lineno)==str(old_lineno):
                                new_products=old_item
                                if int(new_products["RetailType"])==3 or int(new_products["RetailType"])==5:
                                    new_products["Qty"] = "-"+str(u_item["qty"])
                                else:
                                    new_products["Qty"]=str(u_item["qty"])
                                new_products["Price"] =("%.2f" % (float(new_products["ActualPrice"]) * int(new_products["Qty"])))  # 实收金额
                                update_product(j,new_products)
                                break
                    res["data"] = GetProducts()
                    res["message"] = ""
                    res["code"] = 0
                    res["type"] = "sku"  # 返回的是条码信息
                    # 获取条码统计信息
                    total = GetProductsTotal()
                    res["total"] = total
                    return res

        except Exception as e:
            raise OperationError(-1, str(e.__str__()))

    def update_pricelist(self,products=[]):
        '''
        修改相应行的价格
        :param products:
        :return:
        '''
        res={}
        try:
            pros = GetProducts()
            if pros:
                if products:
                    for i in range(len(products)):
                        u_item = products[i]
                        u_lineno = u_item["lineno"]
                        u_type=u_item["type"]
                        new_products = {}
                        for j in range(len(pros)):
                            old_item = pros[j]
                            old_lineno = old_item["LineNo"]
                            if str(u_lineno) == str(old_lineno):
                                new_products = old_item
                                if u_type=="F1":
                                    new_products["ActualPrice"]=("%.2f" % (float(u_item["inputvalue"])*float(new_products["RetailPrice"]))) # 实收价格
                                    new_products["ReceivablePrice"]=new_products["ActualPrice"] # 应收价格
                                    new_products["Price"]=("%.2f" % (float(new_products["ActualPrice"])*int(new_products["Qty"]))) #实收金额
                                    new_products["Discount"] = ("%.2f" % (float(new_products["ActualPrice"])/float(new_products["PriceList"])))  # 折扣
                                elif u_type=="F2":
                                    new_products["ActualPrice"]=("%.2f" % float(u_item["inputvalue"])) # 实收价格
                                    new_products["ReceivablePrice"]=new_products["ActualPrice"] # 应收价格
                                    new_products["Price"]=("%.2f" % (float(new_products["ActualPrice"])*int(new_products["Qty"]))) #实收金额
                                    new_products["Discount"] = ("%.2f" % (float(new_products["ActualPrice"])/float(new_products["PriceList"])))  # 折扣
                                elif u_type=="F3":
                                    new_products["Price"]=("%.2f" % float(u_item["inputvalue"])) # 实收金额
                                    new_products["ActualPrice"] = ("%.2f" % (float(new_products["Price"])/int(new_products["Qty"])))  # 实收价格
                                    new_products["ReceivablePrice"]=new_products["ActualPrice"] # 应收价格
                                    new_products["Discount"] = ("%.2f" % (float(new_products["ActualPrice"])/float(new_products["PriceList"])))  # 折扣
                                elif u_type=="F4":
                                    new_products["Price"]=("%.2f" % (float(new_products["Price"])-float(u_item["inputvalue"]))) # 实收金额
                                    new_products["ActualPrice"] = ("%.2f" % (float(new_products["Price"])/int(new_products["Qty"])))  # 实收价格
                                    new_products["ReceivablePrice"]=new_products["ActualPrice"] # 应收价格
                                    new_products["Discount"] = ("%.2f" % (float(new_products["ActualPrice"])/float(new_products["PriceList"])))  # 折扣
                                update_product(j, new_products)
                                break
                    res["data"] = GetProducts()
                    res["message"] = ""
                    res["code"] = 0
                    res["type"] = "sku"  # 返回的是条码信息
                    # 获取条码统计信息
                    total = GetProductsTotal()
                    res["total"] = total
                    return res
        except Exception as e:
            raise OperationError(-1, str(e.__str__()))

    def update_saler(self,param={}):
        '''
        修改相应行的数量
        :param products:
        :return:
        '''
        res = {}
        try:
            pros = GetProducts()
            if pros:
                if param:
                    lineno=param["lineno"]
                    saler_id=param["saler_id"]
                    new_products={}
                    for j in range(len(pros)):
                        old_item=pros[j]
                        old_lineno=old_item["LineNo"]
                        if lineno==old_lineno:
                            new_products=old_item
                            n_saler=self.get_salersById(saler_id)
                            print("营业员"+n_saler)
                            update_product(j,new_products)
                            break
                    res["data"] = GetProducts()
                    res["message"] = ""
                    res["code"] = 0
                    res["type"] = "sku"  # 返回的是条码信息
                    # 获取条码统计信息
                    total = GetProductsTotal()
                    res["total"] = total
                    return res

        except Exception as e:
            raise OperationError(-1, str(e.__str__()))

if __name__=='__main__':


    rt=Retail()
    print(rt.get_salersById(6491))
    # rt.get_productpic()
    # rrr=[]
    # print(type(rrr))
    # from flask import jsonify,json
    # rt=Retail()
    # param={"product":[{"pro_sku":"6T60959006","saler_id":1,"qty":1,"retail_type":1}], "input_mode":"skus" }
    # jsons=rt.SearchProducts(param)
    # print(jsons)
